// pages/my/getmoney/money.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userinfo:{},
    withdrawMoney:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    // this.data.userinfo = app.globalData.userinfo;
    this.setData({
      userinfo: app.globalData.userinfo
    });
  },

  changeDb: function (e) {
    var values = e.detail.value;
    this.data.withdrawMoney = values;
  },
  withdrawfun:function(){
    //提现
    this.withdraw();
  },
  withdraw: function () {

    if (this.data.withdrawMoney<0.3){
      wx.showToast({
        title: '金额不少于0.3元',
        icon: 'none'
      });
      return;
    }
    var url = app.globalData.webUrl + 'Payment/withdraw_handle';
    var saveObject = { money: this.data.withdrawMoney};

    app.loadDataFromServer(url, this.loadCallBack, saveObject);
  },
  loadCallBack: function (res) {

    wx.hideToast();
    if (res.status != 'ok') {
      wx.showToast({
        title: res.msg,
        icon:"none",
        duration:3000
        // image: '../../imgs/tips.png'
      });
      return;
    }

    wx.showToast({
      title: res.msg
    });
    app.globalData.userinfo.accounts = res.result;
    // this.data.userinfo.accounts = this.res.result;
    this.setData({
      userinfo: app.globalData.userinfo
    });
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  }
})